def sortColumns(matrix): # DO NOT modify this line 
    # TODO: add your code here
    l=len(matrix)
    m1=[]
    i=0
    x=len(matrix[0])
    while i<l:
        m1.append(matrix[i])
        i+=1
    i=0
    j=0
    k=0
    while j<x:
        k=0
        while k<l-1:
            i=0
            while i<l-1:
                 if matrix[i][j]>matrix[i+1][j]:
                     temp=matrix[i][j]
                     matrix[i][j]=matrix[i+1][j]
                     matrix[i+1][j]=temp
                 i+=1
            k+=1
        j+=1
    return matrix# You can modify or delete this line

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===